package com.teradata.fbj.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.teradata.fbj.pojo.linkParams;
import com.teradata.fbj.service.IExcelDataService;

@Controller
@RequestMapping(value="/")
public class ExcelDataController {
	
	@Autowired
	private IExcelDataService excelDataService;
	

	@RequestMapping(value="/loadData.action",method=RequestMethod.POST)
	@ResponseBody
	public void loadData (@RequestBody Map<String, Object> paramsMap){
		List<List<String>> excelData = (List<List<String>>)paramsMap.get("excelData");
		//List<List<String>> dataList = new ArrayList<List<String>>();
		String tableName = (String)paramsMap.get("tableName");
		linkParams lp = new linkParams();
		lp.setDriverClass((String)paramsMap.get("driverClass"));
		lp.setBaseUrl((String)paramsMap.get("baseUrl"));
		lp.setUsername((String)paramsMap.get("username"));
		lp.setPassword((String)paramsMap.get("password"));
		excelDataService.loadData(excelData, lp, tableName);
		
	}
}
